package com.chinacoal.hr.levelapi.util;

/**
 * @author: YunTao.Li
 * @create: 2019-12-12 17:09
 * @description:
 **/
public class CodeMsg {
    private int code;
    private String msg;
    public static final CodeMsg Success = new CodeMsg(10000, "localsuccess");
    public static final CodeMsg SERVER_ERROR = new CodeMsg(10001, "local服务端异常: %s");
    public static final CodeMsg BIND_ERROR = new CodeMsg(10002, "local参数校验异常: %s");
    public static final CodeMsg REQUEST_ILLEGAL = new CodeMsg(10003, "local验证码错误");
    public static final CodeMsg ACCESS_LIMIT = new CodeMsg(10004, "local不能频繁访问");
    public static final CodeMsg BATCH_FAIL = new CodeMsg(10005, "local批量操作存在错误: %s");
    public static final CodeMsg NOT_FOUND = new CodeMsg(10006, "local资源不存在");
    public static final CodeMsg METHOD_NOT_SUPPORTED = new CodeMsg(10007, "local不支持的请求类型");
    public static final CodeMsg IllegalArgumentException = new CodeMsg(10008, "local参数转换异常");
    public static final CodeMsg FALLBACK = new CodeMsg(10009, "local服务不可用,请稍后重试s");
    public static final CodeMsg NO_PRIVILEGES = new CodeMsg(10010, "local没有权限访问");
    public static final CodeMsg SQL_ERROR = new CodeMsg(10011, "local主键或唯一键约束失败");
    public static final CodeMsg EXECUTE_ERROR = new CodeMsg(10012, "local程序执行异常，原因: %s");
    public static final CodeMsg NO_DELET_IN_DATA = new CodeMsg(100013, "local内置数据无法删除: %s");
    public static final CodeMsg ERROR_MENUFUN_HAS_CHILDREN = new CodeMsg(10014, "local有子级数据,无法删除");
    public static final CodeMsg ERROR_MENUFUN_IS_AUTH_NOT_DEL = new CodeMsg(10015, "local功能已授权,无法删除");
    public static final CodeMsg NAME_OR_CODE_REPEAT = new CodeMsg(10016, "local名称或编码重复");
    public static final CodeMsg TARGET_DISTRIBUTION = new CodeMsg(10017, "local目标已经分配,不能删除");
    public static final CodeMsg EX_NAME_NOT_SUPPORT = new CodeMsg(10019, "local扩展名不支持");
    public static final CodeMsg USER_IAM_SYNCHRONIZATION_ERROR = new CodeMsg(10020, "localiam用户同步失败 %s");
    public static final CodeMsg EXIST_SUB_LEVEL = new CodeMsg(10021, "local存在子级节点");
    public static final CodeMsg EXIST_REALATION = new CodeMsg(10022, "local存在关联数据");
    public static final CodeMsg EXIST_DATA = new CodeMsg(10022, "local数据已存在");
    public static final CodeMsg ERROR_BUILED_RULE_MAX_ORDER = new CodeMsg(10023, "local编码规则序号已到设置最大值");

    public static final CodeMsg ERROR_FILE_UPLOAD = new CodeMsg(50001, "local文件上传服务异常: %s");
    public static final CodeMsg ERROR_FILE_DEL = new CodeMsg(50002, "local文件删除服务异常: %s");
    public static final CodeMsg ERROR_FILE_UPLOAD_FILE_NAME_EXIS = new CodeMsg(50003, "local同一业务下文件名不能重复,请修改文件名后再上传: %s");
    public static final CodeMsg ERROR_FILE_UPLOAD_FILE_NAME_FORMAT = new CodeMsg(50004, "local文件名格式不符合,文件名不能包含'(数字)',请修改文件名后再上传: %s");
    public static final CodeMsg ERROR_FILE_UPLOAD_FAIL = new CodeMsg(50005, "local文件上传失败: %s");
    public static final CodeMsg FILE_EMPTY = new CodeMsg(50006, "local空文件");
    public static final CodeMsg EXCEL_DATA_ERROR = new CodeMsg(50007, "local%s");

    public static final CodeMsg ERROR_WORKFLOW_INSTANCE = new CodeMsg(90000, "local流程实例创建成功，但流程提交失败，原因：%s");
    public static final CodeMsg ERROR_WORKFLOW_SUBMIT = new CodeMsg(90001, "local流程实例创建失败，流程提交失败，原因：%s");
    public static final CodeMsg ERROR_WORKFLOW_APPROVAL = new CodeMsg(90200, "local审批失败，原因：%s");
    public static final CodeMsg ERROR_WORKFLOW_TASK = new CodeMsg(90300, "local获取待办列表失败，原因：%s");
    public static final CodeMsg ERROR_WORKFLOW_ACTTASK = new CodeMsg(90400, "local获取已办列表失败，原因：%s");
    public static final CodeMsg ERROR_WORKFLOW_HISTORY = new CodeMsg(90500, "local获取审批历史失败，原因：%s");
    public static final CodeMsg ERROR_WORKFLOW_ACTIVITYLIST = new CodeMsg(90600, "local获取流程活动列表失败，原因：%s");
    public static final CodeMsg ERROR_WORKFLOW_PROCESSTREE = new CodeMsg(90700, "local获取流程树失败，原因：%s");

    private CodeMsg(int code, String msg)
    {
        this.code = code;
        this.msg = msg;
    }
    public CodeMsg fillArgs(Object[] args) {
        int code = this.code;
        String msg = String.format(this.msg, args);
        return new CodeMsg(code, msg);
    }
    public int getCode() {
        return this.code;
    }
    public String getMsg() {
        return this.msg;
    }

    public static void main(String[] args) {
        System.out.println(String.format("提示: %s", new Object[] { "12" }));
        System.out.println(BIND_ERROR.fillArgs(new Object[] { "123" }).getMsg());
    }
}
